﻿// JSON C# Class Generator
// http://at-my-window.blogspot.com/?page=json-class-generator

using System;
using Newtonsoft.Json.Linq;
using log4net;

namespace CommonLib
{

    public class RedfinPropertyClusterData
    {
        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        public RedfinPropertyClusterData(string json)
         : this(JObject.Parse(json))
        {
        }

        public RedfinPropertyClusterData(JObject obj)
        {
            try
            {
                this.maxLong = JsonClassHelper.ReadFloat(JsonClassHelper.GetJToken<JValue>(obj, "maxLong"));
                this.minLat = JsonClassHelper.ReadFloat(JsonClassHelper.GetJToken<JValue>(obj, "minLat"));
                this.count = JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(obj, "count"));
                this.numSfr = JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(obj, "numSfr"));
                this.maxPrice = JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(obj, "maxPrice"));
                this.numCondo = JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(obj, "numCondo"));
                this.id = JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(obj, "id"));
                this.maxLat = JsonClassHelper.ReadFloat(JsonClassHelper.GetJToken<JValue>(obj, "maxLat"));
                this.avgPrice = JsonClassHelper.ReadFloat(JsonClassHelper.GetJToken<JValue>(obj, "avgPrice"));
                this.numOther = JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(obj, "numOther"));
                this.longitude = JsonClassHelper.ReadFloat(JsonClassHelper.GetJToken<JValue>(obj, "longitude"));
                this.latitude = JsonClassHelper.ReadFloat(JsonClassHelper.GetJToken<JValue>(obj, "latitude"));
                this.minLong = JsonClassHelper.ReadFloat(JsonClassHelper.GetJToken<JValue>(obj, "minLong"));
                this.minPrice = JsonClassHelper.ReadInteger(JsonClassHelper.GetJToken<JValue>(obj, "minPrice"));
            }
            catch (Exception e)
            {

                log.DebugFormat("Exception while reading Cluster Data : {0}", e.StackTrace);
            }
        }

        public readonly double maxLong;
        public readonly double minLat;
        public readonly int count;
        public readonly int numSfr;
        public readonly int maxPrice;
        public readonly int numCondo;
        public readonly int id;
        public readonly double maxLat;
        public readonly double avgPrice;
        public readonly int numOther;
        public readonly double longitude;
        public readonly double latitude;
        public readonly double minLong;
        public readonly int minPrice;
    }
}
